package org.ceteca.explica.core.management;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.ceteca.explica.core.common.BaseVO;

public class SerialNumberOT extends BaseVO implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long idSerialNumber;
	private String description;
	private long value;
	private String prefix;
	private DocumentTypeOT documentType;
	private Integer version=new Integer(0);
	
	
	
	
	
	
	
	
	
	
	
	public void setVersion(Integer version) {
		this.version = version;
	}


	public DocumentTypeOT getDocumentType() {
		return documentType;
	}


	public void setDocumentType(DocumentTypeOT documentType) {
		this.documentType = documentType;
	}


	public Integer getVersion() {
		return version;
	}


	public long getIdSerialNumber() {
		return idSerialNumber;
	}

	public void setIdSerialNumber(long idSerialNumber) {
		this.idSerialNumber = idSerialNumber;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getValue() {
		return value;
	}

	public void setValue(long value) {
		this.value = value;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	
	
	@Override
	public boolean equals(Long id) {
		return id==this.getIdSerialNumber();
	}

	@Override
	public String getEntityId() {
		return InterfaceManagement.EXPLICA_ENTITY_SERIALNUMBER_ID;
	}

	@Override
	public long getInternalId() {
		return this.getIdSerialNumber();
	}

	@Override
	public String getInternalValue() {
		return this.getPrefix();
	}

	
	   @Override
	    public int hashCode() {
	        final HashCodeBuilder hcb = new HashCodeBuilder();
	        hcb.append(getDocumentType());
	        hcb.append(getPrefix());

	        return hcb.toHashCode();
	    }

	    
	    
	    @Override
	    public boolean equals(Object obj) {
	        boolean isEquals = false;
	        try {
	            final SerialNumberOT other = (SerialNumberOT)obj;
	            final EqualsBuilder eqb = new EqualsBuilder();
	            eqb.append(getDocumentType(), other.getDocumentType());
	            eqb.append(getPrefix(), other.getPrefix());
	            isEquals = eqb.isEquals();

	        } catch (Exception e) {
	            isEquals = false;
	        }

	        return isEquals;
	    }

	
	
}
